<?php

if (!defined('NV_IS_MOD_NEWS'))
    die('Stop!!!');

$blocknewsid = 2;

global $global_config, $module_name, $module_data, $module_file, $global_array_cat, $module_config, $module_info;
$array_block_news = array();

$xtpl = new XTemplate( "block_list_short_news.tpl", NV_ROOTDIR . "/themes/" . $module_info['template'] . "/modules/" . $module_file );
$sql = "SELECT * FROM `" . NV_PREFIXLANG . "_" . $module_data . "_rows` WHERE `status`= 1 AND `publtime` < " . NV_CURRENTTIME . " AND (`exptime`=0 OR `exptime`>" . NV_CURRENTTIME . ") ORDER BY `publtime` DESC LIMIT 0,3";
$result = $db->sql_query( $sql );
while ( $row = $db->sql_fetchrow( $result ) ){
    $catid = end( explode( ",", $row['listcatid'] ) );
    $alias = $row['alias'];
    $id = $row['id'];
    $link = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $global_array_cat[$catid]['alias'] . "/" . $alias . "-" . $id;
    $news = array();
    $news['image_url'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_name . '/' . $row['homeimgfile'];
//    $size = @getimagesize( NV_UPLOADS_REAL_DIR . '/' . $module_name . '/' . $row['homeimgfile'] );
    $news['image_width'] = $module_config[$module_name]['blockwidth'];
//    $news['image_height'] = $size[1];
    $news['image_alt'] = ! empty( $row['homeimgalt'] ) ? $row['homeimgalt'] : $row['title'];


    
    $news['title'] = $row['title'];
    $news['link'] = $link;
    $news['short_content'] = nv_clean60(strip_tags($row['hometext']), 100);
    
    $xtpl->assign( 'news', $news );
    $xtpl->parse( 'main.short_news.loop' );
}
$xtpl->parse('main.short_news');
$xtpl->parse('main');
$content = $xtpl->text( 'main' );
